﻿<Page x:Class="Dispatchr.Client.Views.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:controls="using:Dispatchr.Client.Controls"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:Dispatchr.Client.Views"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:prismmvvm="using:Microsoft.Practices.Prism.Mvvm"
      xmlns:designTimeData="using:Dispatchr.Client.DesignTimeData"
      prismmvvm:ViewModelLocator.AutoWireViewModel="True"
      mc:Ignorable="d">

    <d:Page.DataContext>
        <designTimeData:MainPageViewModel />
    </d:Page.DataContext>

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Command="{Binding RefreshCommand}"
                          Icon="Refresh"
                          Label="Refresh" />
        </CommandBar>
    </Page.BottomAppBar>

    <Grid Background="{StaticResource AppBackground}">
        <Hub Margin="0,40,0,0">
            <HubSection MinWidth="{Binding Width, Source={StaticResource HeroSize}}"
                        Header="LATEST">
                <DataTemplate>
                    <controls:HeroGridView HeroSize="{StaticResource HeroSize}"
                                           IsItemClickEnabled="True"
                                           ItemClick="HeroGrid_ItemClick"
                                           NormalSize="{StaticResource NormalSize}"
                                           SelectionMode="None">
                        <ItemsControl.ItemsSource>
                            <Binding Path="Appointments" />
                        </ItemsControl.ItemsSource>
                        <ItemsControl.ItemTemplateSelector>
                            <controls:HeroTemplateSelector HeroTemplate="{StaticResource HubHeroTemplate}"
                                                           NormalTemplate="{StaticResource HubNormalTemplate}" />
                        </ItemsControl.ItemTemplateSelector>
                        <controls:HeroGridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemHeight="{Binding Height, Source={StaticResource ItemSize}}"
                                                       ItemWidth="{Binding Width, Source={StaticResource ItemSize}}"
                                                       MaximumRowsOrColumns="{Binding Height, Source={StaticResource HeroSize}}" />
                            </ItemsPanelTemplate>
                        </controls:HeroGridView.ItemsPanel>
                    </controls:HeroGridView>
                </DataTemplate>
            </HubSection>
            <HubSection Header="APPOINTMENTS">
                <DataTemplate>
                    <controls:MapView Width="{Binding Width, Source={StaticResource MapSize}}"
                                      Height="{Binding Height, Source={StaticResource MapSize}}"
                                      Appointments="{Binding Appointments}"
                                      Zoom="{StaticResource MapZoom}" />
                </DataTemplate>
            </HubSection>
        </Hub>
        <local:Header DataContext="{Binding HeaderViewModel}" />
        <controls:Loading Text="Loading..."
                          Visibility="{Binding Loading, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"
                          d:IsHidden="True" />
    </Grid>

</Page>